<?php

namespace App\Models;

use App\Traits\ModelEventTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Builder;

/**
 * @mixin Builder
 */
class MarketingActive extends Model
{
    use ModelEventTrait;
    use SoftDeletes;

    const KEY = 'id';
    const TABLE = 'sp_marketing_active';

    protected $table = self::TABLE;
    protected $primaryKey = self::KEY;
    protected $connection = 'mysql';

    // public $timestamps = false;
    const CREATED_AT = 'create_time';
    const UPDATED_AT = 'update_time';
    const DELETED_AT = 'delete_time';

    protected $guarded = [];


    protected $hidden = [
        self::DELETED_AT,
    ];

    protected $casts = [
        'create_time' => 'datetime:Y-m-d H:i:s',
        'update_time' => 'datetime:Y-m-d H:i:s',
    ];

    public function getContentAttribute()
    {
        return json_decode($this->attributes['content'], true);
    }


    public function getAll()
    {
        return (new static())->select('id','name','status','goods_class_id','brand_id')->get();
    }


}
